<template>
  <div>
    <el-dialog
      title="消息回复"
      :visible.sync="visible"
      width="30%"
      :before-close="handleClose"
    >
      <div style="margin: 0 0 1% 0">
        <span>商品编号:</span><span>{{ form.id }}</span>
      </div>
      <div style="margin: 0 0 1% 0">
        <span>用户名:</span> <span>{{ form.username }}</span>
      </div>
      <div style="margin: 0 0 1% 0">
        <span>评论:</span> <span>{{ form.comment }}</span>
      </div>
      <div style="margin: 2% 0 0;">
        <el-input
          type="textarea"
          autosize
          placeholder="请输入内容"
          v-model="form.textarea"
        >
        </el-input>
      </div>
      <div style="margin: 2% 0 0;">
        <el-button type="primary" @click="reCall" size="small">回复</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {reCaller} from '@/api/shop'
export default {
  data() {
    return {
      visible: false,
      form: {
        id: "", //商品订单
        username: "", //商家名称
        comment: "", //评论
        textarea:"",//回复内容
        commentId:"" 
      },
    };
  },
  methods: {
    handleClose() {
      this.visible = false;
    },
    reCall(){
       console.log(this.form,'oopp')
       let obj={
        answer:this.form.textarea,
        commentId:this.form.commentId
       }
       reCaller(obj).then(res=>{
        if(res.code==200){
            this.$message.success("已回复")
            this.$nextTick(()=>{
                this.form.comment=''
                this.visible=false
                this.$parent.getList()
            })
        }
       })
    }
  },
};
</script>

<style>
</style>